import React, { Component } from 'react';
import { Modal, Button, Form, Input, Select, Radio, Checkbox, Row, Col, InputNumber } from 'antd';
import Enum from '../Enum'
import './style.less'
import moment from 'moment';
import TheUpload from "@/components/TheUpload";
import { apiAddReport } from '@/request/riskControl'
const { TextArea } = Input;
export default class HandleDialog extends Component {
    constructor(props) {
        super(props)
        this.formRef = React.createRef()
        this.state = {
            mode: 'F',// F  风控封禁   J  风控解禁  UF 账号封禁  UJ 账号解禁  CF 功能封禁   CJ 功能解禁 
            type: "user", // user  账号  content 宠圈内容
            visible: false,
            loading: false,
            timeData: {},
            fileList: []
        }
    }
    componentDidMount() {
    }


    // 上传图片
    getFileResult = (value) => {
        if (value.length) {
            let str = value.map(v => {
                if (v.response && v.response.code === 0) {
                    return v.response.data
                }
            }).join(',')
            this.formRef.setFieldsValue({ reviewImages: str });
        } else {
            this.formRef.setFieldsValue({ reviewImages: '' });
        }
    };
    getData() { }
    // 打开弹窗
    open({ mode = 'F', type = "user" } = {}) {
        this.setState({ mode, type, visible: true })
    }
    // 提 交
    handleOk = async () => {
        this.formRef.validateFields().then(async (values) => {
            console.log(values);
            await apiAddReport({ ...values,dataId:values.reportMemberId, reviewType: "MEMBER_ACCOUNT" }).then(res => {
                if (res.code === 0) {
                    React.$message({
                        type: 'success',
                        content: `新增成功`
                    })
                    this.handleCancel()
                    this.props.getData()
                }
            })
        })
    }
    // 关 闭
    handleCancel = () => {
        this.setState({ visible: false })
    }
    render() {
        const { visible, loading, mode, type, fileList } = this.state
        return (
            <Modal
                visible={visible}
                title={'新增'}
                width={800}
                onOk={this.handleOk}
                onCancel={this.handleCancel}
                footer={[
                    <Button onClick={this.handleCancel}>
                        关 闭
                    </Button>,
                    <Button type="primary" loading={loading} onClick={this.handleOk}>
                        提 交
                    </Button>,
                    <Button
                        key="link"
                        href="https://google.com"
                        type="primary"
                        loading={loading}
                        onClick={this.handleOk}
                    >

                    </Button>,
                ]}
            >
                <Form ref={ref => this.formRef = ref} initialValues={{}}>
                    <Form.Item style={{ marginBottom: 20 }} label="用户ID" name={'reportMemberId'} rules={[{ required: true, message: '请输入' }]}>
                        <InputNumber />
                    </Form.Item>
                    <Form.Item style={{ marginBottom: 20 }} label="举报描述" name={'reviewDescribe'} rules={[{ required: true, message: '请输入' }]}>
                        <TextArea
                            placeholder="请输入"
                            showCount
                            maxLength={100}
                        />
                    </Form.Item>
                    <Form.Item label="图片凭证" name={'reviewImages'} rules={[{ required: true }]} >
                        <TheUpload getFileResult={this.getFileResult} len={9} fileList={fileList} />
                    </Form.Item>
                </Form>

            </Modal >
        );
    }
}
